package com.blibili.web.controller;

import com.blibili.web.service.IUserInfoService;
import com.wf.captcha.SpecCaptcha;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.blibili.common.result.Result;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author thz
 * @since 2025-04-29
 */
@Controller
@RequestMapping("/account")
public class UserInfoController {

    @Autowired
    private IUserInfoService userInfoService;

    @RequestMapping("/checkCode")
    @ResponseBody
    public Result<String> checkCode(HttpSession session) {
        // 使用SpecCaptcha替代ArithmeticCaptcha
        SpecCaptcha captcha = new SpecCaptcha(100, 42);
        String code = captcha.text();
        session.setAttribute("checkCode", code);
        String checkCodeBase64 = captcha.toBase64();
        return Result.ok(checkCodeBase64);
    }
}
